﻿@model RegisterIM
@{
    ViewBag.Title = "注册";
}

@section header{
    <link href="~/Content/iconfont/fontawesome/css/font-awesome.min.css" rel="stylesheet" />
    
}


<div class="container page-register">
    <h3 class="sectiontitle">
        @ViewBag.Title
    </h3>
    <div class="panel panel-default">
        <div class="panel-body">
            <div class="registerbox">
                @using (Ajax.BeginForm("Register", null, new AjaxOptions
                {

                    HttpMethod = "POST",
                    OnBegin = "onBeginSave",
                    OnComplete = "onCompleteSave",
                    OnSuccess = "updateSuccess"

                }, new { role = "form" }))
                {
                    @Html.AntiForgeryToken()
                    @Html.ValidationSummary(true)



                    <div class="form-group">
                        @Html.LabelFor(u => u.UserName)
                        @Html.TextBoxFor(m => m.UserName, new { @class = "form-control", placeholder = Labels.UserName })
                        @Html.ValidationMessageFor(model => model.UserName)
                    </div>
                    <div class="form-group">
                        @Html.LabelFor(u => u.Password)
                        @Html.PasswordFor(m => m.Password, new { @class = "form-control", placeholder = Labels.Password })
                        @Html.ValidationMessageFor(model => model.Password)
                    </div>
                    <div class="form-group">
                        @Html.LabelFor(u => u.ConfirmPassword)
                        @Html.PasswordFor(m => m.ConfirmPassword, new { @class = "form-control", placeholder = Labels.ConfirmPassword })
                        @Html.ValidationMessageFor(model => model.ConfirmPassword)
                    </div>
                    <div class="form-group">
                        @Html.LabelFor(u => u.Email)
                        @Html.TextBoxFor(m => m.Email, new { @class = "form-control", placeholder = Labels.Email })
                        @Html.ValidationMessageFor(model => model.Email)
                    </div>
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary btn-block" id="btnSave"><i class="fa fa-plus fa-fw"></i>  @Buttons.Register </button>
                    </div>
                    <p>@Html.ActionLink(Buttons.AlreadyHaveAccountLoginNow, "Login")</p>


                }
            </div>

        </div>
    </div>

</div>





@section footer {
    @Scripts.Render("~/bundles/jqueryvalWithBootstrap")
    <script>

        function onBeginSave() {
            $("#btnSave i").removeClass("fa-plus").addClass("fa-spinner fa-spin");
        }
        function onCompleteSave() {
            $("#btnSave i").removeClass("fa-spinner fa-spin").addClass("fa-plus");
        }

        function updateSuccess(data) {
            var title = '@ViewBag.Title';
            Common.ShowBoxWithFunc(data, title, RegisterOK);
        }

        function RegisterOK() {
           
                setTimeout(function () {
                    location.href = "@Url.Action("Index","Home")";
                }, 1000);           
        }

        $(function () {

        });
    </script>


}
